package org.ice.struct;

import java.util.Arrays;

public class IString implements CharSequence {
    private final char[] value;

    public IString(char[] value) {
        this.value = value;
    }

    private IString(char[] value, int start, int end) {
        this.value = Arrays.copyOfRange(value, start, end);
    }

    @Override
    public int length() {
        return value.length;
    }

    @Override
    public char charAt(int i) {
        return value[i];
    }

    @Override
    public CharSequence subSequence(int start, int end) {
        return new IString(value, start, end - start);
    }
}
